package com.example.vv.model.Flash;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.appcompat.app.AppCompatActivity;

import com.example.vv.R;
import com.example.vv.model.main.MainActivity;
import com.gyf.immersionbar.ImmersionBar;
import com.race604.drawable.wave.WaveDrawable;

import java.util.Timer;
import java.util.TimerTask;

import butterknife.BindView;
import butterknife.ButterKnife;

public class FlashActivity extends AppCompatActivity {

    @BindView(R.id.imageView)
    ImageView imageView;

    static boolean iss = false;
    ImmersionBar immersionBar;
    @BindView(R.id.layout)
    LinearLayout layout;
    private Timer timer = new Timer();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_flash);
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                startActivity(new Intent(FlashActivity.this, MainActivity.class));
                finish();
            }
        };
        getSupportActionBar().hide();
        setBarColor();
        ButterKnife.bind(this);
        layout.setBackgroundColor(getResources().getColor(R.color.c_cacaca));

        WaveDrawable waveDrawable = new WaveDrawable(this, R.drawable.ic_launcher_foreground);//本地图片
        waveDrawable.setWaveLength(100);//设置波长
        waveDrawable.setWaveSpeed(5);//设定波的移动速度
        waveDrawable.setWaveAmplitude(5);//设置波幅
        waveDrawable.setIndeterminate(true);//运行不确定模式,一直运行
        waveDrawable.setLevel(40);//设置水位
//        waveDrawable.setIndeterminateAnimator();//自定义动画,设置不确定模式下的波浪加载动画
        imageView.setImageDrawable(waveDrawable);//设置
        if (iss) {
            timer.schedule(task, 0);
        } else {
            timer.schedule(task, 2000);
            iss = true;
        }
    }

    public void setBarColor() {
        immersionBar = ImmersionBar.with(this)
                .statusBarDarkFont(true);
        immersionBar.init();
    }
}